// 此处是项目初始化时需要的组件初始化位置.

// 构建 API 调用的 axios
import { AxiosUtil } from "ys-ts/src/ts/axios";
import { Instance } from "ys-ts/src/ts/instance";
import { useConfigStore } from "@/plugins/store";
import { Axios } from "axios";

export let nameApiAxios: string;

export function useApiAxios() {
  nameApiAxios = "api";

  const { base } = useConfigStore();

  return Instance.Instance().getOrSetFunc<Axios>(nameApiAxios, () => {
    return AxiosUtil.newAxios({
      baseURL: base.apiHost,
      timeout: 60 * 1000, // Timeout
      withCredentials: true, // Check cross-site Access-Control
    });
  });
}
